//
//  BaseViewController.m
//  Brand
//
//  Created by Faker on 3/31/14.
//  Copyright (c) 2014 Faker. All rights reserved.
//

#import "config.h"
#import "BaseViewController.h"
#import "UIView+EidanSize.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.stateBarDisplay=YES;
        self.autoRotate = NO;
        self.supportedInterfaceOri = UIInterfaceOrientationMaskPortrait;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    //Customer Navbar
    self.navTopView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, !isiOS6 ? 64 : 44)];
    self.navTopView.backgroundColor = ColorWithHexAlpha(0x1E3C53, 1.0);
    self.stateBarDisplay = YES;
    self.view.clipsToBounds = YES;
    
}

//画导航栏里的内容
-(void)drawNavTopContentView:(UIView *)contentView
{
    contentView.top = !isiOS6 ? 20 : 0;
    contentView.left = 0;
    [self.navTopView addSubview:contentView];
    [self.view addSubview:self.navTopView];
}


- (void)didReceiveMemoryWarning{
    [super didReceiveMemoryWarning];
}


//针对ios7的 导航栏处理，通过改变值，然后刷导航条，就会调用prefersStatusBarHidden这个函数，来让导航条是否可见，调用preferredStatusBarStyle来改变文字颜色
-(void)handleTheStateBarAnimationDur:(float) dur andDisplay:(BOOL)display{
    if (isiOS7) {
        self.stateBarDisplay=display;
        [UIView animateWithDuration:dur animations:^{
            [self setNeedsStatusBarAppearanceUpdate];
        }];
    }
}

//控制状态栏可见性
- (BOOL)prefersStatusBarHidden
{
    return !self.stateBarDisplay;
}

//状态栏文字颜色
-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

////控制状态栏方向
-(NSUInteger)supportedInterfaceOrientations
{
    return self.supportedInterfaceOri;
}

-(BOOL)shouldAutorotate{
    return self.autoRotate;
}




@end
